package com.CloudDream.Inventory;

import com.CloudDream.Item.Creator;
import com.CloudDream.Item.Dye;
import com.CloudDream.Item.Potion;
import com.CloudDream.MoonCake;
import com.CloudDream.Util.CustomHead;
import com.CloudDream.Util.TextUtil;
import com.cryptomorin.xseries.XMaterial;
import com.handy.lib.util.BaseUtil;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import java.util.Arrays;
import java.util.List;

public class InventoryItem {

    public static MoonCake instance = MoonCake.getInstance();

    public final ItemStack TABLE;
    public final ItemStack LR;
    public final ItemStack WUREN;
    public final ItemStack DH;
    public final ItemStack BT;
    public final ItemStack MG;
    public final ItemStack RS;
    public final ItemStack GW;

    public InventoryItem() {

        List<String> tableLore = Arrays.asList("", "§7使用 §b/mc table §7打开合成界面", "§7放入所需材料", "§7即可合成不同种类的月饼", "", "§a点击打开");
        this.TABLE = new Creator(XMaterial.CRAFTING_TABLE.parseMaterial(), "§a通过工作台合成", tableLore, 0, false).get();

        //莲蓉月饼
        String lr_name = TextUtil.ReplaceText("MoonCake.lianrong.DisplayName");
        List<String> lr_lore = TextUtil.ReplaceTexttoList("MoonCake.lianrong.lores");
        this.LR = new Creator(Material.COOKIE, lr_name, lr_lore, 0, true).get();

        //五仁月饼
        String wr_name = TextUtil.ReplaceText("MoonCake.wuren.DisplayName");
        List<String> wr_lore = TextUtil.ReplaceTexttoList("MoonCake.wuren.lores");
        this.WUREN = new Creator(Material.COOKIE, wr_name, wr_lore, 0, true).get();

        //蛋黄月饼
        String dh_name = TextUtil.ReplaceText("MoonCake.danhuang.DisplayName");
        List<String> dh_lore = TextUtil.ReplaceTexttoList("MoonCake.danhuang.lores");
        this.DH = new Creator(Material.COOKIE, dh_name, dh_lore, 0, true).get();

        //冰糖月饼
        String bt_name = TextUtil.ReplaceText("MoonCake.bingtang.DisplayName");
        List<String> bt_lore = TextUtil.ReplaceTexttoList("MoonCake.bingtang.lores");
        this.BT = new Creator(Material.COOKIE, bt_name, bt_lore, 0, true).get();

        //玫瑰月饼
        String mg_name = TextUtil.ReplaceText("MoonCake.meigui.DisplayName");
        List<String> mg_lore = TextUtil.ReplaceTexttoList("MoonCake.meigui.lores");
        this.MG = new Creator(Material.COOKIE, mg_name, mg_lore, 0, true).get();

        //肉松月饼
        String rs_name = TextUtil.ReplaceText("MoonCake.rousong.DisplayName");
        List<String> rs_lore = TextUtil.ReplaceTexttoList("MoonCake.rousong.lores");
        this.RS = new Creator(Material.COOKIE, rs_name, rs_lore, 0, true).get();

        //果味月饼
        String gw_name = TextUtil.ReplaceText("MoonCake.guowei.DisplayName");
        List<String> gw_lore = TextUtil.ReplaceTexttoList("MoonCake.guowei.lores");
        this.GW = new Creator(Material.COOKIE, gw_name, gw_lore, 0, true).get();

    }

    public static ItemStack getGift() {
        String name = TextUtil.ReplaceText("Gift.DisplayName");
        List<String> lore = BaseUtil.replaceChatColor(instance.getConfig().getStringList("Gift.lores"), false);

        return new CustomHead().getSkull("7ba3be83ed47502fb1a141d3a785ff96f2856ef3862233854405dbf8dabe427", name, lore, "§1§2§3§4§5");
    }

    public static ItemStack getMoonCake(int number) {

        ItemStack Item = null;
        List<String> lore;
        String name;

        switch (number) {
            case 0:
                name = TextUtil.ReplaceText("MoonCake.lianrong.DisplayName");
                lore = BaseUtil.replaceChatColor(instance.getConfig().getStringList("MoonCake.lianrong.lores"),false);
                Item = new Creator(Material.COOKIE, name, lore, 0, true).get();
                break;
            case 1:
                name = TextUtil.ReplaceText("MoonCake.wuren.DisplayName");
                lore = BaseUtil.replaceChatColor(instance.getConfig().getStringList("MoonCake.wuren.lores"),false);
                Item = new Creator(Material.COOKIE, name, lore, 0, true).get();
                break;
            case 2:
                name = TextUtil.ReplaceText("MoonCake.danhuang.DisplayName");
                lore = BaseUtil.replaceChatColor(instance.getConfig().getStringList("MoonCake.danhuang.lores"), false);
                Item = new Creator(Material.COOKIE, name, lore, 0, true).get();
                break;
            case 3:
                name = TextUtil.ReplaceText("MoonCake.bingtang.DisplayName");
                lore = BaseUtil.replaceChatColor(instance.getConfig().getStringList("MoonCake.bingtang.lores"),false);
                Item = new Creator(Material.COOKIE, name, lore, 0, true).get();
                break;
            case 4:
                name = TextUtil.ReplaceText("MoonCake.meigui.DisplayName");
                lore = BaseUtil.replaceChatColor(instance.getConfig().getStringList("MoonCake.meigui.lores"),false);
                Item = new Creator(Material.COOKIE, name, lore, 0, true).get();
                break;
            case 5:
                name = TextUtil.ReplaceText("MoonCake.guowei.DisplayName");
                lore = BaseUtil.replaceChatColor(instance.getConfig().getStringList("MoonCake.guowei.lores"),false);
                Item = new Creator(Material.COOKIE, name, lore, 0, true).get();
                break;
            case 6:
                name = TextUtil.ReplaceText("MoonCake.rousong.DisplayName");
                lore = BaseUtil.replaceChatColor(instance.getConfig().getStringList("MoonCake.rousong.lores"),false);
                Item = new Creator(Material.COOKIE, name, lore, 0, true).get();
                break;
        }
        return Item;
    }

    public static ItemStack getMaterial(int number) {

        ItemStack Item = null;
        List<String> lore;

        switch (number) {

            case 0:
                lore = Arrays.asList("", "§7想要制作出外皮香脆的月饼", "§7外皮的制作是不可忽视的步骤哦");
                Item = new Creator(Material.WHEAT, "§a月饼皮", lore, 0, true).get();
                break;
            case 2:
                lore = Arrays.asList("", "§7制作月饼皮的基础原料", "§c直接饮用会产生", "&c不良反应");
                Item = new Potion(Material.POTION, "§a枧水", lore, Color.ORANGE, true).get();
                break;
            case 3:
                lore = Arrays.asList("", "§7制作月饼皮的基础原料", "§c直接饮用会产生", "§c不良反应");
                Item = new Potion(Material.POTION, "§a花生油", lore, Color.YELLOW, true).get();
                break;
            case 4:
                lore = Arrays.asList("", "§7制作月饼皮的基础原料");
                Item = new Potion(Material.POTION, "§a糖浆", lore, Color.WHITE, true).get();
                break;
            case 5:
                lore = Arrays.asList("", "§7制作月饼皮的基础原料");
                Item = new Creator(Material.PRISMARINE_CRYSTALS, "§a盐", lore, 0, true).get();
                break;
            case 6:
                lore = Arrays.asList("", "§7制作月饼皮的基础原料");
                Item = new Creator(Material.MILK_BUCKET, "§a奶粉", lore, 0, true).get();
                break;
            case 7:
                lore = Arrays.asList("", "§7作为制作冰糖月饼的基础馅料");
                Item = new Creator(Material.ICE, "§a冰糖", lore, 0, true).get();
                break;
            case 8:
                lore = Arrays.asList("", "§7作为制作玫瑰月饼的基础馅料", "§7由糖、水和玫瑰混合而成");
                Item = new Creator(XMaterial.POPPY.parseMaterial(), "§a玫瑰馅", lore, 0, true).get();
                break;
            case 9:
                lore = Arrays.asList("", "§7作为制作果味月饼的基础馅料", "§7使用糖、水、苹果、西瓜片和胡萝卜混合而成");
                Item = new Creator(Material.APPLE, "§a果酱", lore, 0, true).get();
                break;
            case 10:
                lore = Arrays.asList("", "§7作为制作肉松月饼的基础馅料", "§7使用糖、鸡肉、兔肉、猪肉和牛肉混合而成");
                Item = new Creator(Material.COOKED_CHICKEN, "§a肉松", lore, 0, true).get();
                break;
            case 11:
                lore = Arrays.asList("", "§7作为制作莲蓉月饼的基础馅料", "§7使用糖、水、绿豆和红豆混合而成");
                Item = new Dye(XMaterial.INK_SAC.parseMaterial(), "§a莲蓉", lore, Color.ORANGE, true).get();
                break;
            case 12:
                lore = Arrays.asList("", "§7作为制作蛋黄月饼的基础馅料", "§7使用糖、鸡蛋和小麦混合而成");
                Item = new Creator(Material.EGG, "§a蛋黄", lore, 0, true).get();
                break;
            case 13:
                lore = Arrays.asList("", "§7作为制作蛋黄月饼的基础馅料", "§7使用鸡蛋和小麦混合而成");
                Item = new Creator(Material.EGG, "§a五仁", lore, 0, true).get();
                break;
        }
        return Item;
    }
}
